import * as types from '../constants/LoginTypes'

const defaultState = {
    loginData:{
        token:null,
        isSuccess:false,
        status:''
    }
}

export default function login(state = defaultState, action) {
    switch (action.type) {
        case types.LOGINING:
            return {
                ...state,
                loginData: {
                    token:null,
                    isSuccess:false,
                    status:'登录中'
                },
            };
        case types.LOGINSUCCESS:
            return {
                ...state,
                loginData: {
                    token:action.token,
                    isSuccess:true,
                    status:'登录成功'
                }
            }
        case types.LOGINFAIL:
            return {
                ...state,
                loginData: {
                    token:null,
                    isSuccess:false,
                    status:'登录失败'
                }
            }
        default:
            return state;
    }
}